import akshare as ak
from datetime import datetime, timedelta

today = datetime.now().date()
stock = '000001'  # 替换为你想检查的股票代码
stock_data = ak.stock_zh_a_hist(symbol=stock, 
                                period="daily", 
                                start_date=(today - timedelta(days=30)).strftime("%Y%m%d"), 
                                end_date=today.strftime("%Y%m%d"))
# .shape[0] 会返回筛选后的 DataFrame 的行数，即收红的天数。
red_days = stock_data[stock_data['收盘'] > stock_data['开盘']].shape[0]
print(f"Red days for {stock}: {red_days}")